package com.ticket.controller;

import com.ticket.entity.Collect;
import com.ticket.entity.StageCollect;
import com.ticket.service.CollectService;
import com.ticket.service.StageService;
import com.ticket.service.impl.CollectServiceImpl;
import com.ticket.service.impl.StageServiceImpl;
import com.ticket.util.Page;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO   用户收藏控制器
 * @date 2023/10/11 9:19
 */
public class UserCollectController {

    CollectService cs = new CollectServiceImpl();

    /**
     * @author 全谢民
     * @description TODO    用户查看个人收藏
     * @date 2023/10/15 17:04
     * @param request
     * @param response
     * @return java.lang.Object
     */
    public Object userCollectAll(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        Page<Collect> page = new Page(4,1);
        String pageIndex = request.getParameter("index");
        if(pageIndex!=null && pageIndex!=""){
            page.setCurrPageNo(Integer.parseInt(pageIndex));
        }
        //获取值
        int userId = Integer.parseInt(request.getParameter("userId"));
        String activityType = request.getParameter("activityType");
        session.setAttribute("activityType",activityType);
        Collect collect = new Collect(userId,activityType);
        page = cs.selUserCollectList(collect,page);
        request.setAttribute("page",page);
        return "forward:/user_page/userCollection.jsp";
    }
    /**
     * @author 全谢民
     * @description TODO    用户删除个人收藏
     * @date 2023/10/16 14:23
     * @param request
     * @param response
     * @return java.lang.Object
     */
    public Object userDelCollect(HttpServletRequest request, HttpServletResponse response) {
        int collectId = Integer.parseInt(request.getParameter("collectId"));
        int count = cs.delUserCollect(collectId);
        return count;
    }
}
